<template>
  <div class="container">
    <div class="container-head flex_btw">
      <div class="head-title flex_x">
        <img class="head-icon" src="@/assets/images/data.png" alt="" />
        <span>合并任务</span>
      </div>
    </div>
    <div class="container-main">
      <el-form :model="formList" label-width="100" size="large">
        <el-form-item label="任务名称：">
          <el-col :span="10">
            <el-input v-model="formList.name" placeholder="请输入预警名称"
          /></el-col>
        </el-form-item>
        <el-row>
          <el-col :span="8">
            <el-form-item label="任务来源："> 趋势预警 </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="预警名称：">
              A品牌2天不开单店铺预警
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="维度值："> A品牌华阳店 </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="严重程度："> 严重 </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="周期："> 2日 </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="预警趋势：">
          <div id="container" style="height: 200px; width: 30%"></div>
        </el-form-item>
        <el-form-item>
          <el-table
            :data="tableData"
            style="width: 100%"
          >
            <el-table-column prop="date" label="时间" />
            <el-table-column prop="address" label="指标值" />
            <el-table-column prop="name" label="预警内容" />
            <el-table-column prop="con" label="提醒情况" />
          </el-table>
        </el-form-item>
        <el-form-item label="严重程度：">
          <el-radio-group v-model="formList.warn">
            <el-radio value="">警告</el-radio>
            <el-radio value="Venue">严重</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item >
          <div class="mr10">第一级(审核)</div>
          <el-col :span="4" class="mr30">
            <el-select
              v-model="formList.bm"
              placeholder="please select your zone"
            >
              <el-option label="部门" value="" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-col>
          <el-col :span="4" class="mr30">
            <el-select
              v-model="formList.zw"
              placeholder="please select your zone"
            >
              <el-option label="职务" value="" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-select
              v-model="formList.yg"
              placeholder="please select your zone"
            >
              <el-option label="指定员工" value="" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-col>
          <el-col :span="4" class="ml30">
            <el-button type="primary" :icon="Plus" circle size="small" />
            <!-- <el-button type="danger" :icon="Minus" circle size="small" /> -->
          </el-col>
        </el-form-item>
        <el-form-item label="提醒：">
          <div class="mr30 cf5">临期：</div>
          <el-input
            v-model="formList.limitNum"
            class="num_ipt"
            placeholder="Please input"
          />
          <el-col :span="2" class="mr30">
            <el-select
              v-model="formList.date"
              placeholder="please select your zone"
            >
              <el-option label="日" value="" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-col>
          <div class="cf5">超期：</div>
          <el-input
            v-model="formList.limitNum"
            class="num_ipt"
            placeholder="Please input"
          />
          <el-col :span="2" class="mr30">
            <el-select
              v-model="formList.date"
              placeholder="please select your zone"
            >
              <el-option label="日" value="" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-col>
        </el-form-item>

        <el-form-item label="任务内容：">
          <el-col :span="18">
            <el-input v-model="formList.con" type="textarea" :rows="3" />
          </el-col>
        </el-form-item>
        <el-form-item label="上传附件：">
          <el-upload
            v-model:file-list="fileList"
            class="upload-demo"
            action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
            multiple
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :limit="3"
            :on-exceed="handleExceed"
          >
            <el-button type="primary">上传文件</el-button>
            <template #tip>
              <div class="el-upload__tip">
                支持扩展名:.rar .zip .doc .docx.pdf jpg.
              </div>
            </template>
          </el-upload>
        </el-form-item>
      </el-form>
      <div class="flex_c">
        <el-button size="large" @click="router.back()">取消</el-button>
        <el-button size="large" type="primary" @click="onSubmit"
          >新增</el-button
        >
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Search } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import { Plus, Minus } from "@element-plus/icons-vue";
import * as echarts from "echarts";

const router = useRouter();
const params = ref("");
const formList = reactive({
  name: "A品牌2天不开单店铺预警任务处理",
  target: "指标单数",
  range: "店铺",
  store: "",
  limit: "",
  limitNum: "0",
  date: "",
  warn: "",
  con: "A品牌的【店铺】已经2天没有开单，如下是店铺这两天的相关指标数据：【进店数】，【进店数环比】【试衣率】，【试衣率环比】建议动作：暂无",
  bm: "",
  zw: "",
  yg: "",
});
const tableData = [
  {
    date: "2024-1-2 02：00",
    name: "A品牌的华阳店已经2天没有开单，如下是店铺这两天的相关指标数据：进店数：10，进店数环比：-15%试衣率：20%，试衣率环比：-10%建议动作：暂无",
    address: "0",
    con: '已通知（张三（已忽略），李四（已忽略），王五（标记为重点））'
  },
  {
    date: "2024-1-4 01：00",
    name: "A品牌的华阳店已经2天没有开单，如下是店铺这两天的相关指标数据：进店数：12，进店数环比：-12试衣率：21%，试衣率环比：-11%建议动作：暂无",
    address: "0",
    con: '已通知（张三（已忽略），李四（已忽略），王五（标记为重点））'
  },
];
const onSubmit = () => {
  console.log("submit!");
};
onMounted(() => {
  var dom = document.getElementById("container");
  var myChart = echarts.init(dom, null, {
    renderer: "canvas",
    useDirtyRect: false,
  });
  var option;
  option = {
    xAxis: {
      type: "category",
      data: [1,2,3,4,5,6,7],
    },
    yAxis: {
      type: "value",
    },
    series: [
      {
        data: [0, 1, 0, 1, 0, 0, 0],
        type: "line",
      },
    ],
  };

  if (option && typeof option === "object") {
    myChart.setOption(option);
  }
});
</script>
<style lang="scss" scoped></style>
